﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Nhom04_DiaDiemDuLich.DTO;

namespace Nhom04_DiaDiemDuLich.GUI
{
    public partial class UserControlFormKetNoi : UserControl
    {
        public delegate void KetNoi(ThongTinKetNoiDTO info);
        public event KetNoi SuKienKetNoi;

        public UserControlFormKetNoi()
        {
            InitializeComponent();
        }

        private void buttonKetNoi_Click(object sender, EventArgs e)
        {
            string Ip = this.textBoxIpAddress.Text;
            string DBName = this.textBoxDBName.Text;
            string Username = this.textBoxLoginName.Text;
            string Password=this.textBoxPassword.Text;

            if (Ip.Equals("") || DBName.Equals("") || Username.Equals("") || Password.Equals(""))
            {
                MessageBox.Show("Bạn chưa nhập đầy đủ thông tin kết nối !");
            }
            else
            {
                ThongTinKetNoiDTO ThongTinKetNoiDTO = new ThongTinKetNoiDTO();
                ThongTinKetNoiDTO.IpAddress = Ip;
                ThongTinKetNoiDTO.DatabaseName = DBName;
                ThongTinKetNoiDTO.LoginName = Username;
                ThongTinKetNoiDTO.Password = Password;

                if (SuKienKetNoi != null)
                {
                    SuKienKetNoi(ThongTinKetNoiDTO);
                }
            }            
        }

        private void UserControlFormKetNoi_Load(object sender, EventArgs e)
        {

        }




    }
}
